﻿namespace Home.Test
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    public static class ExceptionAssert
    {
        public static void Expect<TException>(Action action)
        {
            Debug.Assert(action != null);

            try
            {
                action();
            }
            catch (Exception ex)
            {
                var type = ex.GetType();
                if (type != typeof(TException))
                {
                    Assert.Fail("The expected exception type is {0}, but actual is {1}", typeof(TException).FullName, type.FullName);
                }
            }
        }
    }
}
